package com.jml.单例模式.反射破坏内部类;

public class LazyInnerClassSingleton {

    //这样可以防止反射暴力创建单例，，在反射前statis的东西就已经被加载进内存，就已经被加载了，反射的时候就会报错
    private LazyInnerClassSingleton() {
        if(LazyHolder.lazyInnerClassSingleton!=null){
            throw new RuntimeException("");
        }
    }

    private static class LazyHolder{
        private static  final LazyInnerClassSingleton lazyInnerClassSingleton = new LazyInnerClassSingleton();
    }

    public static final LazyInnerClassSingleton getInstance(){
        return LazyHolder.lazyInnerClassSingleton;
    }
}
